<template>
  <div class="container">
    <div @click="fly('/')">首页</div>
    <h2>查询结果如下</h2>
    <el-row :gutter="20" class="goods-row">
      <el-col :span="5" v-for="item in catId" :key="item.id" class="goods-col">
        <div class="product-card">
          <img @click="fly('/detail/?id=' + item.id)" :src="require('@/assets/' + item.img)" alt="Product Image" class="product-image">
          <div class="product-details">
            <h3>{{ item.description1 }}</h3>
            <p>￥{{ item.dayPrice }}元/天</p>
            <p>￥{{ item.monthPrice }}元/月</p>
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>
<script>
export default {
  data() {
    return {
      catId: []
    };
  },
  mounted() {
    this.load();
  },
  methods: {
    async load() {
      console.log(111)
      const storedData = localStorage.getItem('catg');
      this.catId =  JSON.parse(storedData);
      console.log(this.catId);
      console.log(111);
    },
    fly(url) {
      location.href = url;
    }
  }
}
</script>

<style scoped>
.container {
  max-width: 1200px;
  margin: 20px auto;
  padding: 20px;
  background-color: #f9f9f9;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

h2 {
  text-align: center;
  margin-bottom: 20px;
  color: #333;
}

.goods-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.goods-col {
  flex: 0 0 20%; /* Adjust the grid layout as needed */
  max-width: 20%;
}

.product-card {
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
}

.product-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.product-image {
  width: 100%;
  height: auto;
  display: block;
  cursor: pointer;
}

.product-details {
  padding: 15px;
  text-align: center;
}

h3 {
  margin: 0;
  font-size: 18px;
  color: #333;
}

p {
  margin: 5px 0;
  font-size: 14px;
  color: #666;
}
</style>